package com.hnl.util;

import javax.servlet.http.HttpServletRequest;

public class DataTablesParamUtility {

	public static JQueryDataTableParamModel getParam(HttpServletRequest request) {
		if (request.getParameter("sEcho") != null
				&& request.getParameter("sEcho") != "") {
			JQueryDataTableParamModel param = new JQueryDataTableParamModel();
			param.sEcho = Integer.valueOf(request.getParameter("sEcho"));
			param.sSearch = request.getParameter("sSearch");
			param.sColumns = request.getParameter("sColumns");
			param.iDisplayStart = Integer.parseInt(request
					.getParameter("iDisplayStart"));
			param.iDisplayLength = Integer.parseInt(request
					.getParameter("iDisplayLength"));
			param.iColumns = Integer.parseInt(request.getParameter("iColumns"));
			param.iSortingCols = Integer.parseInt(request
					.getParameter("iSortingCols"));
			param.iSortColumnIndex = (request.getParameter("iSortCol_0") == null) ? 0
					: Integer.parseInt(request.getParameter("iSortCol_0"));
			param.sSortDirection = request.getParameter("sSortDir_0");
			return param;
		} else
			return null;
	}
}
